﻿/*****************************************************************************//*!
* file  : test.c
* creat : apleilx
* data  : 2017/03/02
*******************************************************************************/
#define   osObjectsCreat                                        // define objects in rtxapp module
#include "os_obj.h"                                          // RTOS object definitions

void  app_task_system(ULONG thread_input);
void  app_task_idle(ULONG thread_input);
void  flash_task(ULONG thread_input);
void  usb_main(ULONG thread_input);

void    tx_filex_application_define(void);

/*----------------------------------------------------------------------------
 *      Thread 1 'Thread_Name': Sample thread
 *---------------------------------------------------------------------------*/

int os_thread_init(void)
{
	os_obj_creat();

	/**************创建启动任务*********************/
	tx_thread_create(&os_obj.tcb_app_task_system,       //task tcb 
		"App Task Start",              //task name
		app_task_system,                  //task entry
		0,                             //task argv
		&os_obj.stk_app_task_system[0], //task stack
		sizeof(os_obj.stk_app_task_system),   //stack size 
		APP_CFG_TASK_START_PRIO,       //task priority
		APP_CFG_TASK_START_PRIO,       //priority force sw
		TX_NO_TIME_SLICE,              //time slice off
		TX_AUTO_START);                //auto start
	os_obj.tid_systask = &os_obj.tcb_app_task_system;

	tx_thread_create(&os_obj.tcb_flash,       //task tcb 
		"flash task",              //task name
		flash_task,                  //task entry
		2,                             //task argv
		&os_obj.stk_task_flash[0], //task stack
		sizeof(os_obj.stk_task_flash),   //stack size 
		APP_CFG_TASK_FLASH_PRIO,       //task priority
		APP_CFG_TASK_FLASH_PRIO,       //priority force sw
		TX_NO_TIME_SLICE,              //time slice off
		TX_AUTO_START);                //auto start 
	os_obj.tid_flash = &os_obj.tcb_flash;

	tx_thread_create(&os_obj.tcb_task_idle,       //task tcb 
		"idle task",              //task name
		app_task_idle,                  //task entry
		1,                             //task argv
		&os_obj.stk_task_idle[0], //task stack
		sizeof(os_obj.stk_task_idle),   //stack size 
		APP_CFG_TASK_IDLE_PRIO,       //task priority
		APP_CFG_TASK_IDLE_PRIO,       //priority force sw
		TX_NO_TIME_SLICE,              //time slice off
		TX_AUTO_START);                //auto start  
	os_obj.tid_idle = &os_obj.tcb_task_idle;

	tx_thread_create(&os_obj.tcb_task_usb,       //task tcb 
		"usb task",              //task name
		usb_main,                  //task entry
		5,                             //task argv
		&os_obj.stk_task_usb[0],    //task stack
		sizeof(os_obj.stk_task_usb),   //stack size 
		APP_CFG_TASK_USB_PRIO,       //task priority
		APP_CFG_TASK_USB_PRIO,       //priority force sw
		TX_NO_TIME_SLICE,              //time slice off
		TX_AUTO_START);                //auto start  
	os_obj.tid_usb = &os_obj.tcb_task_usb;

	return(0);
}

/*----------------------------------------------------------------------------
 *  creat thread object
 *---------------------------------------------------------------------------*/
int os_thread_creat(void)
{






	return 0;
}

/*----------------------------------------------------------------------------
 *  creat os object
 *---------------------------------------------------------------------------*/
int os_obj_creat(void)
{
	tx_queue_create(
		&os_obj.que_flash_cb,
		"flash_quene",
		1,
		os_obj.que_flash_buff,
		sizeof(os_obj.que_flash_buff)
		);
	os_obj.qid_flash = &os_obj.que_flash_cb;


	tx_event_flags_create(&os_obj.event_mb,
		"event mb");
	os_obj.eid_mb = &os_obj.event_mb;


	return(0);
}
